const baseUrl = "http://47.108.197.28:";
function http(url){
  return new Promise((resolve,reject)=>{
    wx.request({
      url,
      header:{"content-type":"application"},
      method:"GET",
      dataType:"json",
      responseType:"text",
      success:res=>resolve(res),
      fail:err=>reject(err)
    })
  })
}
function getMusicUrl(offset){
  return http(`http://47.108.197.28:3000/top/album?offset=${offset}&limit=20`)
}

function handleStr(str){
  if(str.length>12){
    str = str.slice(0,12) + "..."
  }
  return str;
}
module.exports = {
  http,
  getMusicUrl,
  handleStr
}